/*
 * This file is part of GuitarMaster.
 * 
 * GuitarMaster is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * GuitarMaster is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with GuitarMaster.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.paris5.master2.guitarmaster.dao;

/*
 * $Id: EcomDao.java 21 2013-03-26 23:42:25Z nedjahi.mourad@gmail.com $
 * 
 * $HeadURL: https://com-paris5-master2-guitarmaster-ejb.googlecode.com/svn/trunk/com.paris5.master2.guitarmaster-ejb/src/java/com/paris5/master2/guitarmaster/dao/EcomDao.java $
 * $Revision: 21 $
 * $Date: 2013-03-27 00:42:25 +0100 (mer., 27 mars 2013) $
 * $Author: nedjahi.mourad@gmail.com $
 */
import com.paris5.master2.guitarmaster.exception.EcomQueryException;
import java.util.List;
import java.util.Map;
import javax.ejb.Local;

/**
 * @author Leticia Mahamed, Alice Khammy, mourad nedjahi, Saliou Mamadou Barry
 * 
 * Data access interface
 */
@Local 
public interface EcomDao {

    /**
     * Insert entity into db
     * @param obj 
     */
    public void insert(Object obj);

    /**
     * update untity into db
     * @param obj 
     */
    public void update(Object obj);

    /**
     * delete entity from fb
     * @param obj 
     */
    public void delete(Object obj);

    /**
     * search entity by primary key
     * @param c Class
     * @param id Object id
     * @return Object entity
     */
    public Object find(Class c, Object id);

    /**
     * execute a named query
     * @param namedQuery named query
     * @param parameters Map<String, Object> query bindings
     * @return List<Object>
     * @throws EcomQueryException 
     */
    public Object execute(String namedQuery, Map<String, Object> parameters) throws EcomQueryException;
    
    /**
     * execute a named query
     * @param namedQuery named query
     * @param parameters Map<String, Object> query bindings
     * @return List<Object>
     * @throws EcomQueryException 
     */
    public List<Object> execute(String namedQuery, Map<String, Object> parameters, int offset, int limit) throws EcomQueryException;
    
    /**
     * execute a named query
     * @param namedQuery named query
     * @param parameters List<Object> query bindings (respect parameters order)
     * @return List<Object>
     * @throws EcomQueryException 
     */
    public Object execute(String namedQuery, List<Object> values) throws EcomQueryException;

    /**
     * execute a named query
     * @param method named query
     * @param parameters List<Object> query bindings (respect parameters order)
     * @return List<Object>
     * @throws EcomQueryException 
     */
    public List<Object> execute(String query, List<Object> values, int offset, int limit) throws EcomQueryException;
    
    
    /**
     * 
     * @param eq
     * @param values
     * @return
     * @throws EcomQueryException 
     */
    public Object execute(EcomQuery eq, List<Object> values) throws EcomQueryException;

    /**
     * 
     * @param eq
     * @param values
     * @param offset
     * @param limit
     * @return
     * @throws EcomQueryException 
     */
    public List<Object> execute(EcomQuery eq, List<Object> values, int offset, int limit) throws EcomQueryException;

    /**
     * return an interval of rows
     * @param entity Class 
     * @param offset from
     * @param limit  to
     * @param count  select fields or count ?
     * @return List<Object> or 
     */
    public List<Object> findAll(Class entity, int offset, int limit);
    
    /**
     * count table row
     * @return int
     */
    public int countAll(Class entity);
}
